import  {createSlice} from "@reduxjs/toolkit"

export const  listInfo = createSlice({
    name:"listInfo",
    initialState:[],
    reducers:{
        initList:(state,{payload})=>{//payload是集合
            console.log(payload);
            return  payload;
        },
        delList:(state,{payload})=>{ //id
            return state.filter((item:any)=>item.id!==payload);
        
        },
        addListItem:(state:any,{payload}:any)=>{
            state= [...state,payload];
            return  state;
        }
    }
})
export const {initList,delList,addListItem} = listInfo.actions;

export  default  listInfo.reducer;